import weeklyreport.User

class BootStrap {

	def init = { servletContext ->
		environments {
			development {
				//Admin
				def admin = new User(
						name : "Admin",
						password : "Abcd",
						role : "admin"
						)
				admin.save()
				if(admin.hasErrors()) {
					println admin.errors
				}

			}
			production {
				def admin = User.findByRole("admin")
				if(!admin) {
					admin = new User(
							name : "Admin",
							password : "Abcd",
							role : "admin"
							)
					admin.save()
					if(admin.hasErrors()) {
						println admin.errors
					}
				}
			}
		}
	}
	def destroy = {
	}
}
